package com.lin.databases;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * Created by zjingchuan on 2017/5/12.
 */
public class MultipleDataSource extends AbstractRoutingDataSource {
    private static ThreadLocal<String> routeKey = new ThreadLocal<String>();

    @Override
    protected Object determineCurrentLookupKey() {
        return routeKey.get();
    }

    public static void setRouteKey(String key) {
        routeKey.set(key);
    }

    public static void removeRouterKey() {
        routeKey.remove();
    }
}
